package SlidingWindow;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-10-09
 * Time: 19:07
 */
class Solution {
    public int minSubArrayLen(int target, int[] nums) {
        int left = 0 , right = 0 , sum = 0 , n = nums.length;
        int len = Integer.MAX_VALUE;

        for(;right < n ; right++){
            //进入窗口
            sum += nums[right];
            while(sum >= target){
                //更新值
                len = Math.min(len,right - left + 1);
                //出窗口
                sum -= nums[left];
                left++;
            }
        }
        return len == Integer.MAX_VALUE ? 0 : len;




    }
}
public class test1 {

}
